package com.jiang.专题.数组.Q238;

import java.util.Arrays;

/**
 * @author Jiang
 * @version 1.0
 * @date 2024/12/21 22:22
 */
class Solution {
    public int[] productExceptSelf(int[] nums) {
        int len = nums.length;
        int[] res = new int[len];
        Arrays.fill(res, 1);
        int l = 1;
        int r = 1;
        for (int i = 0, j = len - 1; i < len; i++, j--) {
            res[i] *= l;
            res[j] *= r;
            l *= nums[i];
            r *= nums[j];
        }
        return res;
    }
}
